package com.ctgu.demo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctgu.demo.dao.PuddingMapper;
import com.ctgu.demo.entity.Pudding;
import com.ctgu.demo.service.PuddingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @program:
 * @description:
 * @author: gh
 * @create: 2020-06-22 12:36
 **/
@Service
public class PuddingServiceImpl extends ServiceImpl<PuddingMapper, Pudding> implements PuddingService {
    @Autowired
    private PuddingMapper puddingMapper;

    @Override
    public IPage<Pudding> getAll(int page, int size) {
        QueryWrapper<Pudding> wrapper =new QueryWrapper<Pudding>();
        IPage<Pudding> puddingIPage = puddingMapper.selectPage(new Page<>(page,size), wrapper);
        return puddingIPage;
    }
    @Override
    public IPage<Pudding> selectPudding(String name, int page, int size){
        QueryWrapper<Pudding> puddingIPage = new QueryWrapper<>();
        puddingIPage.like("pudding_id", name).or().like("pudding_name", name).or().like("pudding_maker", name);
        IPage<Pudding> puddingsMapper = puddingMapper.selectPage(new Page<>(page, size), puddingIPage);
        return puddingsMapper;
    }
}
